//
//  GWEmotionPopView.m
//  新浪微博
//
//  Created by qianfeng on 16/2/21.
//  Copyright (c) 2016年 高炜. All rights reserved.
//

#import "GWEmotionPopView.h"
#import "GWEmotionView.h"
@interface GWEmotionPopView()

@property (weak, nonatomic) IBOutlet GWEmotionView *emotionView;

@end

@implementation GWEmotionPopView
-(void)popViewShowWithEmotionView:(GWEmotionView *)fromEmotionView
{
    if (fromEmotionView==nil) return;
    UIWindow *window =[[UIApplication sharedApplication].windows lastObject];
    self.emotionView.emotion =fromEmotionView.emotion;
    [window addSubview:self];
    CGFloat centerX =fromEmotionView.center.x;
    CGFloat centerY =fromEmotionView.center.y-self.height*0.5;
    CGPoint center =CGPointMake(centerX, centerY);
    self.center =[window convertPoint:center fromView:fromEmotionView.superview];
}
-(void)dismiss
{
    [self removeFromSuperview];
}
+(instancetype)popView
{
    return [[[NSBundle mainBundle] loadNibNamed:@"GWEmotionPopView" owner:nil options:nil]lastObject];
}



- (void)drawRect:(CGRect)rect {
    
    [[UIImage imageNamed:@"emoticon_keyboard_magnifier"]drawAsPatternInRect:rect];
}


@end
